const dbutil = require('../../../libs/MyDB');

module.exports = {
    //显示所有权限
    show_allAuthority: async function() {
        let result = [];
        await dbutil.multiSelect('study_auth_rule', ['rule_name', 'rule_url', 'parent_id'], 'rule_id is not null')
            .then(
                res => {
                    result = res;
                }
            )
        //  console.log(result);
        return result;
    },

    //添加权限
    add_authority: async function(authority, url, parentId) {
        await dbutil.add('study_auth_rule', {
            'rule_name': authority,
            'rule_url': url,
            'parent_id': parentId
        })
    },

    //删除权限
    delete_authority: async function(authority) {
        await dbutil.del('study_auth_rule', `rule_name='${authority}'`);
    }
}

